//
//  ECMemberSourceViewController.m
//  ECERP.CRM
//
//  Created by 刘思麟 on 2018/10/23.
//  Copyright © 2018年 Mac. All rights reserved.
//

#import "ECMemberSourceViewController.h"
#import "ECMemberSourceTableViewCell.h"
#import "GLHTTPTool.h"

@interface ECMemberSourceViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) UITableView * tableView;

@end

@implementation ECMemberSourceViewController

- (void)viewDidLoad {
    self.navigationItem.title = @"客户来源";
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)listDateRequest {
    NSString * url = Api_MemberList(@"o");
    NSMutableDictionary * paraDic = @{@"page":@(1),@"limit":@(20),}.mutableCopy;
    [GLHTTPTool getWithURL:url params:paraDic success:^(id json) {
        
    } failure:^(NSError *error) {
        
    }];
}

- (void)loadSubView {
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.bottom.mas_equalTo(0);
    }];
    
    UIBarButtonItem * searchItem = [[UIBarButtonItem alloc] initWithCustomView:({
        UIImageView * imgView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"search_icon"] imageByResizeToSize:CGSizeMake(22, 28) contentMode:UIViewContentModeLeft]];
        imgView;
    })];
    UIBarButtonItem * addItem = [[UIBarButtonItem alloc] initWithCustomView:({
        UIImageView * imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"add_icon"]];
        imgView;
    })];
    self.navigationItem.rightBarButtonItems = @[addItem,searchItem];
    [self listDateRequest];
}

#pragma mark -UITableViewDelegate,UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 11;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 60 * PX_RELATIVE375;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ECMemberSourceTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.titleLB.text = @"易升鲜";
    if (indexPath.row % 2 == 1) {
        cell.isForbid = YES;
    }
    return cell;
}

#pragma mark LazyLoad

- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [UITableView new];
        _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0.00000001)];
        _tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0.00000001)];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.sectionHeaderHeight = 12 * PX_RELATIVE375;
        _tableView.sectionFooterHeight = 0.00001 * PX_RELATIVE375;
        [_tableView registerClass:[ECMemberSourceTableViewCell class] forCellReuseIdentifier:@"cell"];
        _tableView.bounces = NO;
        _tableView.delegate = self;
        _tableView.dataSource = self;
    }
    return _tableView;
}

@end
